package com.daqsoft.service;

import com.daqsoft.dao.UserDao;
import com.daqsoft.data.User;
import com.daqsoft.dto.ExtTreeNode;
import com.daqsoft.service.system.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 周麟东 on 17:30
 */
@Service
public class UserService {

    @Autowired
    private UserDao userDao;
    @Autowired
    private PermissionService ps;

    /**
     * 用户登录
     * @param username 用户名
     * @param password 密码
     * @return 返回用户是否成功
     */
    public User login(String username , String password){
        return userDao.findByUsernameAndPassword(username,password);
    }

    /**
     * 通过用户获取模块
     * @param user 用户对象
     * @return 模块对象列表
     */
    public List<ExtTreeNode> getUserModules(User user) {
        return ps.getModuleByUser(user);
    }



}
